/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.beijing.dh2011.security.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Obama
 */
@Entity
@Table(name = "SECURITY_ACCOUNT_ROLE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SecurityAccountRole.findAll", query = "SELECT s FROM SecurityAccountRole s"),
    @NamedQuery(name = "SecurityAccountRole.findByAccountRoleId", query = "SELECT s FROM SecurityAccountRole s WHERE s.accountRoleId = :accountRoleId")})
public class SecurityAccountRole implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "ACCOUNT_ROLE_ID")
    private String accountRoleId;
    @JoinColumn(name = "ROLE_ID", referencedColumnName = "ROLE_ID")
    @ManyToOne
    private SecurityRole roleId;
    @JoinColumn(name = "ACCOUNT_ID", referencedColumnName = "ACCOUNT_ID")
    @ManyToOne
    private SecurityAccount accountId;

    public SecurityAccountRole() {
    }

    public SecurityAccountRole(String accountRoleId) {
        this.accountRoleId = accountRoleId;
    }

    public String getAccountRoleId() {
        return accountRoleId;
    }

    public void setAccountRoleId(String accountRoleId) {
        this.accountRoleId = accountRoleId;
    }

    public SecurityRole getRoleId() {
        return roleId;
    }

    public void setRoleId(SecurityRole roleId) {
        this.roleId = roleId;
    }

    public SecurityAccount getAccountId() {
        return accountId;
    }

    public void setAccountId(SecurityAccount accountId) {
        this.accountId = accountId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountRoleId != null ? accountRoleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SecurityAccountRole)) {
            return false;
        }
        SecurityAccountRole other = (SecurityAccountRole) object;
        if ((this.accountRoleId == null && other.accountRoleId != null) || (this.accountRoleId != null && !this.accountRoleId.equals(other.accountRoleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.herenit.beijing.dh2011.security.SecurityAccountRole[ accountRoleId=" + accountRoleId + " ]";
    }
    
}
